package com.yxy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yxy.mapper.PetMapper;
import com.yxy.pojo.Pet;
import com.yxy.pojo.PetExample;
import com.yxy.service.PetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PetServiceImpl implements PetService {
    @Autowired
    private PetMapper pm;

    @Override
    public PageInfo<Pet> pageAll(int index, int pagesize) {
        PageHelper.startPage(index,pagesize);
        List<Pet>list=pm.selectByExample(null);
        PageInfo<Pet>info=new PageInfo<>(list);

        return info;
    }

    @Override
    public int update(Pet p) {
        return pm.updateByPrimaryKey(p);
    }

    @Override
    public int add(Pet p) {
        return pm.insert(p);
    }

    @Override
    public int delete(int id) {
        return pm.deleteByPrimaryKey(id);
    }
}
